Skip to content

fix(id): count intra-interval revoke+re-add cycles in group churn watcher (#1847) - #4035

Merged
dezren39 merged 3 commits into
mainfrom
queue/5048-1847-churn-intra-interval
Nov 2, 2026
Merged

dezren39 merged 3 commits into
mainfrom
queue/5048-1847-churn-intra-interval

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #1847 (queue task 5048).

Problem

GroupWarningWatcher::evaluate counted re-adds by comparing the net device set between evaluations. A revoke + re-add cycle that completes inside one 60s evaluation interval leaves the net set unchanged, so it counted zero re-adds — a device cycling faster than once a minute could churn indefinitely without ever reaching the churn threshold.

Change (pkgs/id/src/commands/serve.rs only)

  • The watcher now counts re-adds from the group log events folded since its previous evaluation: it keeps a cursor into the log (events_seen), tracks per-group authorization through the event stream, and counts an applied DeviceOp::Add for a device it has seen authorized before and that is not authorized at that point in the stream. Only events the fold Applied count — a refused authorization/revocation changes nothing.
  • The first evaluation only establishes the baseline (adopts the fold's current devices, counts nothing): group events carry no timestamps, so churn from before serve started is never reconstructed — startup behaviour unchanged.
  • A log that shrank since the previous evaluation (replaced) re-baselines instead of counting.
  • The tracked authorization set is reconciled against the fold each pass (account removal/re-add can move a device without a device event); such moves are not counted as re-adds, they only keep the tracked set truthful.
  • CHURN_THRESHOLD, CHURN_WINDOW_SECS, the evaluator's once-per-burst / re-arm semantics, the 60s interval, size warnings, and the startup pass are unchanged. Re-adds are still stamped with the evaluating pass's time and age out of the 24h window exactly as before.

Tests

  • New watcher-level regression test serve_group_warnings_fire_on_intra_interval_readd_churn: four revoke+re-add cycles written to the group log with no evaluation in between, then one evaluation, fires Warning::Churn { readds: 4 }.
  • Existing serve_group_warnings_fire_on_device_readd_churn (straddling cycles) covers the unchanged path: each cycle's add event is folded by the following evaluation and counted once.
  • Verification is GitHub Actions CI on this PR (fleet CI-first rule; no builds run on the sandbox).

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 22:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T14:56:49.038139Z aa5acd3 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e317ee9e-eeb8-4989-aa49-2b2e8896bd03
Commits

Reviewing files that changed from the base of the PR and between 2f8ab78 and aa5acd3.

Files selected for processing: 1
  • pkgs/id/src/commands/serve.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a7558da8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/commands/serve.rs Resolved
Codex P2 on PR #4035: a device revocation ends only the revoking account's grant in the fold, but the watcher removed the device from the whole group set, so another account's later re-add was counted as churn even though the device stayed authorized throughout. The watcher now tracks the authorizing accounts per device (from device events, and from the fold at baseline) and removes a device only when its last grant ends. Adds a regression test: four revoke+re-add cycles by a second account while the first account's grant stands produce no churn warning. For #1847.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87c31e071b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/id/src/commands/serve.rs Resolved
The evaluation reconciliation kept the device keys in step with the
fold but preserved the tracked authorizing-account sets untouched.
When an account that had authorized a device was removed from the
group, its stale entry kept the device authorized through every
later revoke by the remaining accounts, so genuine revoke+re-add
cycles never counted as churn (Codex review on PR #4035).

Refresh each active device's authorizing accounts from the fold
(Projection::active_devices per member) during reconciliation, and
pin it with serve_group_warnings_count_churn_after_a_grant_owner_is_removed:
both accounts authorize, one is removed, then four cycles by the
remaining account inside one interval fire the churn warning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant